import { Ellipsis } from '@/components/Ellipsis';
import '@/pages/design/style.less';
import { getErrorReportMembers, getWorkOrderInforList } from '@/services/platform/errorReport';
import {
  getWorkHoursRequestHstByPage,
  updateWorkHoursRequestHst,
  viewBaseInfo,
} from '@/services/platform/workHoursRequestHst';
import {
  addWorkHoursRequest,
  getProductManufactExecInfosByWoId,
} from '@/services/product/productManufactInforExecute';
import { tableSearchPublicConfig } from '@/utils/filterUtils';
import { filterTranNew, sortTran } from '@/utils/requestUtil';
import { PlusOutlined } from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import type { ActionType, ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
import {
  Button,
  Col,
  DatePicker,
  Form,
  Input,
  InputNumber,
  message,
  Modal,
  Row,
  Select,
  Tabs,
} from 'antd';
import dayjs from 'dayjs';
import localeData from 'dayjs/plugin/localeData';
import weekday from 'dayjs/plugin/weekday';
import moment from 'moment';
import React, { useEffect, useRef, useState } from 'react';
import type { recordInfoType, tabType } from '../platform/components/interfaceProduct';

dayjs.extend(weekday);
dayjs.extend(localeData);
const WorkHoursRequestHst: React.FC<{}> = () => {
  const actionRef = useRef<ActionType>();
  const actionRef_2 = useRef<ActionType>();
  const actionRef_3 = useRef<ActionType>();
  const [modalVisit, setModalVisit] = useState(false); // 新建和编辑提示框
  const [confirmLoading, setConfirmLoading] = useState(false); //编辑框的disable
  const [formTitle, setFormTitle] = useState('审核'); //
  const [createOrUpdate, setCreateOrUpdate] = useState(false); //设置审核描述在待审核弹窗不显示
  const [modalVisit2, setModalVisit2] = useState(false); // 新建和编辑提示框
  const [confirmLoading2, setConfirmLoading2] = useState(false); //编辑框的disable
  const [formTitle2, setFormTitle2] = useState('查看'); //
  const [recordInfo, setrecordinfo] = useState<recordInfoType>();
  const [username, setusername] = useState([]);
  const [handlingname, sethandlingname] = useState([]);
  const [form] = Form.useForm();
  const ref = useRef(null);
  const [handlenumber, sethandlenumber] = useState(''); //待审批的数量
  const [formTitle3, setFormTitle3] = useState(''); //实际项目填报工时弹窗标题
  const [confirmLoading3, setConfirmLoading3] = useState(false); //实际项目填报工时提交loading
  const [modalVisit3, setModalVisit3] = useState(false); //实际项目填报工时新建弹窗
  const { TextArea } = Input;
  const [workOrderInfo, setWorkOrderInfo] = useState(null); //工单编号信息
  const dateFormat = 'YYYY-MM-DD'; //时间格式
  const [operatorMembers, setOperatorMembers] = useState(null); //工时填报人
  const [taskList, setTaskList] = useState(null); //生产工序任务列表下拉框
  const [taskListInfo, setTaskListInfo] = useState(null); //生产工序任务总列表
  const [taskListReady, setTaskListReady] = useState(true); //生产工序任务列表是否就绪
  const [taskRecord, setTaskRecord] = useState(null); //选中的生产工序
  useEffect(() => {
    //异步获取工单编号
    getWorkOrderInfo();
    //获取填报人信息
    getuser();
    //获得审核人名单
    operatorMember();
  }, []);
  const tobereviewed: ProColumns[] = [
    {
      title: '序号',
      dataIndex: 'index',
      valueType: 'index',
      align: 'center',
      sorter: true,
      width: 80,
    },
    {
      title: '审批状态',
      dataIndex: 'status',
      search: false,
      align: 'center',
      sorter: true,
      width: 120,
      render: (text, record, _, action) => {
        return (
          <div>
            {record.status == 1 ? '待审批' : record.status == 2 ? '审批通过' : '驳回待调整'}
          </div>
        );
      },
    },
    {
      title: '审批人',
      dataIndex: 'operator',
      align: 'center',
      sorter: true,

      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '工单编号',
      dataIndex: 'wo',
      width: 180,

      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '柜体编号',
      dataIndex: 'productCode',
      width: 200,

      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '申请人',
      dataIndex: 'requestMan',
      align: 'center',
      sorter: true,

      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '申请时间',
      dataIndex: 'createTime',
      width: 120,

      valueType: 'date',
      align: 'center',
      sorter: true,
      search: false,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    // {
    //   title: '申请描述',
    //   dataIndex: 'requestMemo',
    //   search: false,
    //  align: 'center',sorter: true,
    //   render: (text) => <>{Ellipsis(text)}</>,
    // },
    {
      title: '工序编号',
      dataIndex: 'processCode',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '工序名称',
      dataIndex: 'processName',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '加工顺序编号',
      dataIndex: 'processSequence',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '标准工时(h)',
      dataIndex: 'standManufactWorkhour',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '开始时间',
      dataIndex: 'manufactStartDate',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '结束时间',
      dataIndex: 'manufactEndDate',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    // {
    //   title: '审批申请号',
    //   dataIndex: 'requestId',
    //   search: false,
    // },
    {
      title: '填报工时(h)',
      dataIndex: 'requestWorkHours',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },

    {
      title: 'taskId',
      dataIndex: 'taskId',
      hideInTable: true,
      search: false,
    },
    // {
    // title: '创建人', //表头显示的名称
    // search: false,
    // dataIndex: 'createName',
    // },
    {
      title: '操作',
      valueType: 'option',
      key: 'option',
      fixed: 'right',
      align: 'center',
      width: 120,
      render: (text, record, _, action) => [
        <a
          key="editKey"
          onClick={() => {
            setrecordinfo(record);
            setModalVisit2(true);
            setFormTitle2('查看');
            setCreateOrUpdate(true);
            form.setFieldsValue({
              wo: record.wo,
              createTime: record.createTime,
              taskId: record.taskId,
              operator: record.operator,
              processCode: record.processCode,
              processName: record.processName,
              processSequence: record.processSequence,
              productCode: record.productCode,
              requestId: record.requestId,
              requestWorkHours: record.requestWorkHours,
              standManufactWorkhour: record.standManufactWorkhour,
              // status: record.status,
              approveMemo: record.approveMemo,
              requestMemo: record.requestMemo,
              requestMan: record.requestMan,
              id: record.id,
              manufactStartDate: record.manufactStartDate,
              manufactEndDate: record.manufactEndDate,
            });
          }}
        >
          查看
        </a>,
        <a
          key="requestKey"
          disabled={username != record.operator}
          onClick={() => {
            setrecordinfo(record);
            if (username != record.operator) {
              message.warning('没有审核权限');
            } else if (record.status == 1) {
              setModalVisit2(true);
              setCreateOrUpdate2(true);
              setFormTitle2('审核');
              form.setFieldsValue({
                wo: record.wo,
                createTime: record.createTime,
                taskId: record.taskId,
                operator: record.operator,
                processCode: record.processCode,
                processName: record.processName,
                processSequence: record.processSequence,
                productCode: record.productCode,
                requestId: record.requestId,
                requestWorkHours: record.requestWorkHours,
                standManufactWorkhour: record.standManufactWorkhour,
                // status: record.status,
                approveMemo: record.approveMemo,
                requestMemo: record.requestMemo,
                requestMan: record.requestMan,
                id: record.id,
                manufactStartDate: record.manufactStartDate,
                manufactEndDate: record.manufactEndDate,
              });
            }
          }}
        >
          审核
        </a>,
      ],
    },
  ];

  const passcolumns: ProColumns[] = [
    {
      title: '序号',
      dataIndex: 'index',
      valueType: 'index',
      align: 'center',
      sorter: true,
      width: 60,
    },
    {
      title: '审批状态',
      dataIndex: 'status',
      search: false,
      align: 'center',
      sorter: true,
      width: 80,
      render: (text, record, _, action) => {
        return (
          <div>{record.status == 1 ? '待审批' : record.status == 2 ? '审批通过' : '已驳回'}</div>
        );
      },
    },
    // {
    //   title: '审核描述',
    //   dataIndex: 'approveMemo',
    //   search: false,
    //  align: 'center',sorter: true,
    //   render: (text) => <>{Ellipsis(text)}</>,
    // },
    {
      title: '审批人',
      dataIndex: 'operator',
      align: 'center',
      sorter: true,

      width: 80,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '审批时间',
      dataIndex: 'approveTime',
      align: 'center',
      sorter: true,

      search: false,
      width: 100,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '工单编号',
      dataIndex: 'wo',
      width: 120,

      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '柜体编号',
      dataIndex: 'productCode',
      width: 120,

      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '申请人',
      dataIndex: 'requestMan',
      align: 'center',
      sorter: true,

      width: 80,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '申请时间',
      dataIndex: 'createTime',
      width: 120,

      valueType: 'date',
      align: 'center',
      sorter: true,
      search: false,
      render: (text) => <>{Ellipsis(text)}</>,
    },

    // {
    //   title: '申请描述',
    //   dataIndex: 'requestMemo',
    //   search: false,
    //  align: 'center',sorter: true,
    //   render: (text) => <>{Ellipsis(text)}</>,
    // },
    {
      title: '工序编号',
      dataIndex: 'processCode',
      search: false,
      align: 'center',
      sorter: true,
      width: 80,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '工序名称',
      dataIndex: 'processName',
      search: false,
      align: 'center',
      sorter: true,
      width: 100,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '加工顺序编号',
      dataIndex: 'processSequence',
      search: false,
      align: 'center',
      sorter: true,
      width: 100,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '任务开始时间',
      dataIndex: 'manufactStartDate',
      search: false,
      align: 'center',
      sorter: true,
      width: 100,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '任务结束时间',
      dataIndex: 'manufactEndDate',
      search: false,
      align: 'center',
      sorter: true,
      width: 100,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    // {
    //   title: '审批申请号',
    //   dataIndex: 'requestId',
    //   search: false,
    // },
    {
      title: '填报工时(h)',
      dataIndex: 'requestWorkHours',
      search: false,
      align: 'center',
      sorter: true,
      width: 80,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '标准工时(h)',
      dataIndex: 'standManufactWorkhour',
      search: false,
      align: 'center',
      sorter: true,
      width: 80,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: 'taskId',
      dataIndex: 'taskId',
      hideInTable: true,
      search: false,
    },
    // {
    // title: '创建人', //表头显示的名称
    // search: false,
    // dataIndex: 'createName',
    // },
    {
      title: '操作',
      valueType: 'option',
      key: 'option',
      fixed: 'right',
      align: 'center',
      width: 80,
      render: (text, record, _, action) => [
        <a
          key="editKey"
          onClick={() => {
            setrecordinfo(record);
            setModalVisit2(true);
            setFormTitle2('查看');
            form.setFieldsValue({
              wo: record.wo,
              createTime: record.createTime,
              taskId: record.taskId,
              operator: record.operator,
              processCode: record.processCode,
              processName: record.processName,
              processSequence: record.processSequence,
              productCode: record.productCode,
              requestId: record.requestId,
              requestWorkHours: record.requestWorkHours,
              standManufactWorkhour: record.standManufactWorkhour,
              // status: record.status,
              approveMemo: record.approveMemo,
              requestMemo: record.requestMemo,
              requestMan: record.requestMan,
              id: record.id,
              manufactStartDate: record.manufactStartDate,
              manufactEndDate: record.manufactEndDate,
            });
          }}
        >
          查看
        </a>,
        // <a
        //     key="deleteKey"
        //     onClick={() => {
        //       if (record.status != 1){
        //         Modal.confirm({
        //           title: '删除',
        //           content: '确定要删除吗',
        //           okText: '确认',
        //           cancelText: '取消',
        //           onOk: async () => {
        //           await delWorkHoursRequestHst({ id: record.id });
        //           actionRef_2.current.reload();
        //           },
        //         });
        //       }
        //     }}
        // >
        //     删除
        // </a>,
      ],
    },
  ];

  const opposecolumns: ProColumns[] = [
    {
      title: '序号',
      dataIndex: 'index',
      valueType: 'index',
      align: 'center',
      sorter: true,
      width: 80,
    },
    {
      title: '审批状态',
      dataIndex: 'status',
      search: false,
      align: 'center',
      sorter: true,
      render: (text, record, _, action) => {
        return (
          <div>{record.status == 1 ? '待审批' : record.status == 2 ? '审批通过' : '已驳回'}</div>
        );
      },
    },
    // {
    //   title: '审核描述',
    //   dataIndex: 'approveMemo',
    //   search: false,
    //  align: 'center',sorter: true,
    //   render: (text) => <>{Ellipsis(text)}</>,
    // },
    {
      title: '审批人',
      dataIndex: 'operator',
      align: 'center',
      sorter: true,

      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '审批时间',
      dataIndex: 'approveTime',
      align: 'center',
      sorter: true,

      search: false,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '工单编号',
      dataIndex: 'wo',
      width: 180,

      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '柜体编号',
      dataIndex: 'productCode',
      width: 200,

      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '申请人',
      dataIndex: 'requestMan',
      align: 'center',
      sorter: true,

      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '申请时间',
      dataIndex: 'createTime',
      width: 120,

      valueType: 'date',
      align: 'center',
      sorter: true,
      search: false,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    // {
    //   title: '申请描述',
    //   dataIndex: 'requestMemo',
    //   search: false,
    //  align: 'center',sorter: true,
    //   render: (text) => <>{Ellipsis(text)}</>,
    // },
    {
      title: '工序编号',
      dataIndex: 'processCode',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '工序名称',
      dataIndex: 'processName',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '加工顺序编号',
      dataIndex: 'processSequence',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '标准工时(h)',
      dataIndex: 'standManufactWorkhour',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '任务开始时间',
      dataIndex: 'manufactStartDate',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: '任务结束时间',
      dataIndex: 'manufactEndDate',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    // {
    //   title: '审批申请号',
    //   dataIndex: 'requestId',
    //   search: false,
    // },
    {
      title: '填报工时(h)',
      dataIndex: 'requestWorkHours',
      search: false,
      align: 'center',
      sorter: true,
      render: (text) => <>{Ellipsis(text)}</>,
    },
    {
      title: 'taskId',
      dataIndex: 'taskId',
      hideInTable: true,
      search: false,
    },
    // {
    // title: '创建人', //表头显示的名称
    // search: false,
    // dataIndex: 'createName',
    // },
    {
      title: '操作',
      valueType: 'option',
      key: 'option',
      fixed: 'right',
      align: 'center',
      width: 80,
      render: (text, record, _, action) => [
        <a
          key="editKey"
          onClick={() => {
            setrecordinfo(record);
            setModalVisit2(true);
            setFormTitle2('查看');
            form.setFieldsValue({
              wo: record.wo,
              createTime: record.createTime,
              taskId: record.taskId,
              operator: record.operator,
              processCode: record.processCode,
              processName: record.processName,
              processSequence: record.processSequence,
              productCode: record.productCode,
              requestId: record.requestId,
              requestWorkHours: record.requestWorkHours,
              standManufactWorkhour: record.standManufactWorkhour,
              // status: record.status,
              approveMemo: record.approveMemo,
              requestMemo: record.requestMemo,
              requestMan: record.requestMan,
              id: record.id,
              manufactStartDate: record.manufactStartDate,
              manufactEndDate: record.manufactEndDate,
            });
          }}
        >
          查看
        </a>,
        // <a
        //     key="deleteKey"
        //     onClick={() => {
        //       if (record.status != 1){
        //         Modal.confirm({
        //           title: '删除',
        //           content: '确定要删除吗',
        //           okText: '确认',
        //           cancelText: '取消',
        //           onOk: async () => {
        //           await delWorkHoursRequestHst({ id: record.id });
        //           actionRef_3.current.reload();
        //           },
        //         });
        //       }
        //     }}
        // >
        //     删除
        // </a>,
      ],
    },
  ];

  //获取：用户名（填报人）
  const getuser = async () => {
    const getuserlist = await viewBaseInfo(null);
    setusername(getuserlist.data.name);
  };
  /**
   * @description: 获取所有工单编号
   * @return {*}
   */
  const getWorkOrderInfo = async () => {
    const workOrderInfo = await getWorkOrderInforList(null);
    const newWorkOrderInfo: any[] = [];
    workOrderInfo?.data.map((item: any, index: any) => {
      newWorkOrderInfo.push({ value: item.id, label: item.wo });
    });
    console.log(newWorkOrderInfo);
    setWorkOrderInfo(newWorkOrderInfo);
  };
  const operatorMember = async () => {
    const errorReportMembersArray = await getErrorReportMembers(null);
    setOperatorMembers(
      errorReportMembersArray.data?.map((item) => {
        return { value: item.name, label: item.name };
      }),
    );
  };
  const handleSubmit = async () => {
    setConfirmLoading(true);
    form
      .validateFields()
      .then(async () => {
        const res = form.getFieldsValue();
        const enddata = dayjs(res.manufactEndDate).format('MM');
        const startdata = dayjs(res.manufactStartDate).format('MM');
        if (enddata != startdata) {
          message.warning('工序的开始和结束时间不能跨月');
          setConfirmLoading(false);
        } else if (res.requestWorkHours == 0) {
          message.warning('工时不能为0');
          setConfirmLoading(false);
        } else {
          res.requestWorkHours = parseFloat(res.requestWorkHours).toFixed(2);
          res.manufactEndDate = dayjs(res.manufactEndDate).format(dateFormat);
          res.manufactStartDate = dayjs(res.manufactStartDate).format(dateFormat);
          res.approveMan = res.operator;
          console.log(res, '审核参数');
          const result = await addWorkHoursRequest(res);
          if (result != null) {
            message.success('工时填报成功');
            setModalVisit(false);
            form.res;
            actionRef.current!.reload();
            actionRef_2.current!.reload();
            actionRef_3.current!.reload();
          }
          setConfirmLoading(false);
          setModalVisit(false);
        }
      })
      .catch(() => {
        setConfirmLoading(false);
      });
  };

  const handleSubmit2 = () => {
    setConfirmLoading2(true);
    form
      .validateFields()
      .then(async () => {
        const res = form.getFieldsValue();
        // 获取当前审核人
        const getuserlist = await viewBaseInfo(null);
        res.operator = getuserlist.data.name;
        res.approveTime = moment().format('YYYY-MM-DD HH:mm:ss');
        console.log(res, '审核参数');
        const result = await updateWorkHoursRequestHst(res);
        if (result != null) {
          message.success('审核成功');
          actionRef.current!.reload();
          actionRef_2.current!.reload();
          actionRef_3.current!.reload();
        }
        setConfirmLoading2(false);
        setModalVisit2(false);
      })
      .catch(() => {
        setConfirmLoading2(false);
      });
  };
  //取消查看Modal的弹窗
  const handleCancel = () => {
    setModalVisit2(false);
    setCreateOrUpdate(false);
  };

  //定义Tabs的子结构的数组
  const tabList: tabType[] = [
    {
      name: 'tab1',
      label: '待审批',
      content: (
        <div>
          <ProTable
            headerTitle="待审批记录查询"
            actionRef={actionRef} //用于触发刷新操作等，看api
            rowKey="id" //表格行 key 的取值，可以是字符串或一个函数
            formRef={ref}
            search={tableSearchPublicConfig}
            toolBarRender={(action, { selectedRows }) => [
              <Button
                key="button"
                icon={<PlusOutlined />}
                onClick={() => {
                  setCreateOrUpdate(false);
                  setFormTitle('新建');
                  form.resetFields();
                  form.setFieldsValue({
                    // manufactStartDate: dayjs(new Date(), dateFormat),
                    // manufactEndDate: dayjs(new Date(), dateFormat),
                    requestWorkHours: 0.0,
                    requestMan: username,
                  });
                  setModalVisit(true);
                }}
                type="primary"
              >
                新建
              </Button>,
            ]}
            request={async (params = {}, sort, filter) => {
              const res = { ...params, status: 1 };
              const sorters = sortTran(sort);
              const filters = filterTranNew(res);
              // result:当前页面结果，result_nofilter：当前页面数据数量
              const [result, result_nofilter] = await Promise.all([
                getWorkHoursRequestHstByPage({
                  ...params,
                  sorters: sorters,
                  filters: filters,
                }),
                getWorkHoursRequestHstByPage({
                  ...params,
                  sorters: sorters,
                  filters: [
                    {
                      field: 'status',
                      operator: 'eq',
                      value: 1,
                      andOr: 'and',
                    },
                  ],
                }),
              ]);
              sethandlenumber(result_nofilter.data.totalElements);

              return {
                data: result.data.content,
                total: result.data.totalElements,
                success: result.success,
              };
            }}
            columns={tobereviewed}
            scroll={{ x: 2000, y: 350 }}
            rowSelection={{}}
          />
        </div>
      ),
    },
    {
      name: 'tab2',
      label: '审批通过',
      content: (
        <div>
          <ProTable
            headerTitle="审批通过记录查询"
            actionRef={actionRef_2} //用于触发刷新操作等，看api
            rowKey="id" //表格行 key 的取值，可以是字符串或一个函数
            formRef={ref}
            search={tableSearchPublicConfig}
            request={async (params = {}, sort, filter) => {
              const res = { ...params, status: 2 };
              const sorters = sortTran(sort);
              const filters = filterTranNew(res);
              const result = await getWorkHoursRequestHstByPage({
                ...params,
                sorters: sorters,
                filters: filters,
              });
              return {
                data: result.data.content,
                total: result.data.totalElements,
                success: result.success,
              };
            }}
            columns={passcolumns}
            scroll={{ x: 2200, y: 350 }}
            rowSelection={{}}
          />
        </div>
      ),
    },
    {
      name: 'tab3',
      label: '已驳回',
      content: (
        <div>
          <ProTable
            headerTitle="已驳回记录查询"
            actionRef={actionRef_3} //用于触发刷新操作等，看api
            rowKey="id" //表格行 key 的取值，可以是字符串或一个函数
            formRef={ref}
            search={tableSearchPublicConfig}
            request={async (params = {}, sort, filter) => {
              const res = { ...params, status: -1 };
              const sorters = sortTran(sort);
              const filters = filterTranNew(res);
              const result = await getWorkHoursRequestHstByPage({
                ...params,
                sorters: sorters,
                filters: filters,
              });
              return {
                data: result.data.content,
                total: result.data.totalElements,
                success: result.success,
              };
            }}
            columns={opposecolumns}
            scroll={{ x: 2200, y: 350 }}
            rowSelection={{}}
          />
        </div>
      ),
    },
  ];

  return (
    <PageHeaderWrapper title={false} breadcrumb={undefined}>
      <Tabs
        type="card"
        style={{ backgroundColor: 'white' }}
        items={tabList.map((item, i) => {
          const id = String(i + 1);
          return {
            label:
              i == 0 ? (
                <div className="text">
                  {item.label}
                  <div className="point">
                    <div className="number">{handlenumber}</div>
                  </div>
                </div>
              ) : (
                <div>{item.label}</div>
              ),
            key: id,
            children: <div>{item.content}</div>,
          };
        })}
      />
      <Modal
        title={formTitle}
        visible={modalVisit}
        onOk={handleSubmit}
        confirmLoading={confirmLoading}
        onCancel={() => setModalVisit(false)}
        width={1000}
        destroyOnClose
      >
        <Form
          name="wrap"
          labelCol={{ flex: '110px' }}
          labelAlign="right"
          labelWrap
          form={form}
          wrapperCol={{ flex: 1 }}
          colon={false}
        >
          <Form.Item name="id" label="id" hidden={true}>
            <Input />
          </Form.Item>
          <Form.Item name="requestMan" label="填报人" hidden={true}>
            <Input />
          </Form.Item>
          <Form.Item name="taskId" label="taskId" hidden={true}>
            <Input disabled />
          </Form.Item>
          <Form.Item name="wo" label="wo" hidden={true}>
            <Input disabled />
          </Form.Item>
          <Row gutter={[50, 0]}>
            <Col span={12}>
              <Form.Item
                name="wo"
                label="工单编号"
                rules={[{ required: true, message: '请输入工单编号!' }]}
              >
                <Select
                  options={workOrderInfo}
                  allowClear={true}
                  onChange={async (value, record) => {
                    const tasklist = await getProductManufactExecInfosByWoId(record.value);
                    console.log('生产工序列表', tasklist);
                    if (tasklist.data) {
                      const taskList = [];
                      tasklist.data.map((item) => {
                        taskList.push({ label: item.task, value: item.taskId });
                      });
                      console.log(taskList);
                      setTaskListInfo(tasklist.data);
                      setTaskList(taskList);
                      setTaskListReady(false);
                      form.setFieldsValue({
                        workOrderInforId: value,
                        workOrderInfoCode: record.label,
                        wo: record.label,
                      });
                    } else {
                      message.error('该工单编号下，不存在生产工序，请重新选择!');
                      form.setFieldsValue({
                        task: undefined,
                        requestWorkHours: undefined,
                      });
                      setTaskListReady(true);
                    }
                  }}
                ></Select>
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item
                label="生产任务"
                name="task"
                rules={[{ required: true, message: '请选择任务!' }]}
              >
                <Select
                  options={taskList}
                  disabled={taskList === null}
                  onChange={async (value, record) => {
                    form.setFieldsValue({
                      taskId: value,
                    });
                    taskListInfo?.map((item: any) => {
                      if (item.taskId === value) {
                        setTaskRecord(item);
                      }
                    });
                    console.log(taskRecord);
                  }}
                />
              </Form.Item>
            </Col>
          </Row>
          <Row gutter={[50, 0]}>
            <Col span={12}>
              <Form.Item
                name="manufactStartDate"
                label="任务开始时间"
                rules={[{ required: true, message: '请输入任务开始时间!' }]}
              >
                <DatePicker style={{ width: 340 }} />
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item
                name="manufactEndDate"
                label="任务结束时间"
                rules={[{ required: true, message: '请输入任务结束时间!' }]}
              >
                <DatePicker style={{ width: 340 }} />
              </Form.Item>
            </Col>
            {/* <Col span={12}>
              <Form.Item
                name="standManufactWorkhour"
                label="标准工时(h)"
                rules={[{ required: true, message: '请输入标准工时!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col> */}
          </Row>
          <Row gutter={[50, 0]}>
            <Col span={12}>
              <Form.Item
                name="requestWorkHours"
                label="填报工时(h)"
                rules={[{ required: true, message: '请输入填报工时!' }]}
              >
                <InputNumber
                  min={0.0}
                  style={{ width: 340 }}
                  addonAfter="h"
                  step="0.01"
                  stringMode
                />
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item
                name="requestMan"
                label="填报人"
                rules={[{ required: true, message: '请输入填报人!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
          </Row>

          <Form.Item name="requestMemo" label="填报描述">
            <TextArea autoSize={{ minRows: 3, maxRows: 5 }} placeholder="请输入填报描述！" />
          </Form.Item>
          <Row gutter={[50, 0]}>
            <Col span={12}>
              <Form.Item
                name="operator"
                label="审核人"
                rules={[{ required: true, message: '请输入审核人!' }]}
              >
                <Select options={operatorMembers} allowClear={true} />
              </Form.Item>
            </Col>
          </Row>
        </Form>
      </Modal>
      <Modal
        title={formTitle2}
        visible={modalVisit2}
        onOk={handleSubmit2}
        onCancel={handleCancel}
        confirmLoading={confirmLoading2}
        width={1000}
        destroyOnClose
      >
        <Form
          name="wrap"
          labelCol={{ flex: '110px' }}
          labelAlign="right"
          labelWrap
          form={form}
          wrapperCol={{ flex: 1 }}
          colon={false}
        >
          <Form.Item name="id" label="id" hidden={true}>
            <Input />
          </Form.Item>
          <Form.Item name="operator" label="操作人员" hidden={true}>
            <Input disabled />
          </Form.Item>
          <Form.Item name="taskId" label="taskId" hidden={true}>
            <Input disabled />
          </Form.Item>
          <Row gutter={[50, 0]}>
            <Col span={12}>
              <Form.Item
                name="wo"
                label="工单编号"
                // hidden={true}
                rules={[{ required: true, message: '请输入工单编号!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item
                name="productCode"
                label="柜体编号"
                // hidden={true}
                rules={[{ required: true, message: '请输入产品编号!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
          </Row>
          <Row gutter={[50, 0]}>
            <Col span={12}>
              <Form.Item
                name="processCode"
                label="工序编号"
                // hidden={true}
                rules={[{ required: true, message: '请输入工序编号!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item
                name="processName"
                label="工序名称"
                // hidden={true}
                rules={[{ required: true, message: '请输入工序名称!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
          </Row>
          <Row gutter={[50, 0]}>
            <Col span={12}>
              <Form.Item
                name="processSequence"
                label="加工顺序编号"
                // hidden={true}
                rules={[{ required: true, message: '请输入加工顺序编号!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item
                name="manufactStartDate"
                label="任务开始时间"
                rules={[{ required: true, message: '请输入任务开始时间!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
          </Row>
          <Row gutter={[50, 0]}>
            <Col span={12}>
              <Form.Item
                name="manufactEndDate"
                label="任务结束时间"
                rules={[{ required: true, message: '请输入任务结束时间!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item
                name="standManufactWorkhour"
                label="标准工时(h)"
                rules={[{ required: true, message: '请输入标准工时!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
          </Row>
          <Row gutter={[50, 0]}>
            <Col span={12}>
              <Form.Item
                name="requestWorkHours"
                label="填报工时(h)"
                rules={[{ required: true, message: '请输入填报工时!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item
                name="requestMan"
                label="申请人"
                rules={[{ required: true, message: '请输入填报人!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
          </Row>
          <Row gutter={[50, 0]}>
            <Col span={24}>
              <Form.Item
                name="requestMemo"
                label="申请描述"
                // rules={[{ required: true, message: '请输入填报描述!' }]}
              >
                <Input disabled />
              </Form.Item>
            </Col>
          </Row>
          <Row>
            <Col span={24}>
              <Form.Item
                name="status"
                label="审核状态"
                rules={[{ required: true, message: '请选择审核状态!' }]}
              >
                <Select
                  defaultValue="待审批"
                  disabled={formTitle2 === '查看'}
                  options={[
                    { value: '2', label: '通过' },
                    { value: '-1', label: '驳回' },
                  ]}
                />
              </Form.Item>
            </Col>
          </Row>
          <Row gutter={[50, 0]}>
            <Col span={24}>
              <Form.Item
                name="approveMemo"
                label="审核描述"

                // rules={[{ required: true, message: '请输入审核描述!' }]}
              >
                <TextArea autoSize={{ minRows: 2, maxRows: 6 }} disabled={formTitle2 === '查看'} />
              </Form.Item>
            </Col>
          </Row>
        </Form>
      </Modal>
    </PageHeaderWrapper>
  );
};
export default WorkHoursRequestHst;
